//list.cpp --using a list
#include<iostream>
#include<iterator>
#include<list>
int main()
{
	using namespace std;
	list<int> one(5,2);//list of 5 2s
	int stuff[5]={1,2,4,8,6};
	list<int> two;
	two.insert(two.begin(),stuff,stuff+5);
	int more[6]={6,4,2,4,6,5};
	list<int> three(two);
	three.insert(three.end(),more,more+6);
	
	cout<<"list one:";
	ostream_iterator<int,char> out(cout," ");
	copy(one.begin(),one.end(),out);
	cout<<endl<<"list two:";
	copy(two.begin(),two.end(),out);
	cout<<endl<<"list three:";
	copy(three.begin(),three.end(),out);
	
	three.remove(2);//删去所有的2
	cout<<endl<<"list three minus 2s:";
	copy(three.begin(),three.end(),out);
	
	three.splice(three.begin(),one);//one插入到three.begin()
	three.unique();//删除多余的相同元素
	two.sort();//排序
	three.merge(two);//有序合并
	return 0;
}
